package com.blog.wu.myblog.service;

import com.blog.wu.myblog.base.BaseCrudService;
import com.blog.wu.myblog.dao.PermissionMapper;
import com.blog.wu.myblog.entity.Permission;
import com.blog.wu.myblog.entity.Role;
import com.blog.wu.myblog.entity.UserInfo;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author wuyanshen
 * @Date 2018-10-12 下午5:06
 * @Discription 登录记录业务类
 */
@Service
public class PermissionService extends BaseCrudService<PermissionMapper, Permission> {

    public List<Permission> findPermissions(UserInfo userInfo) {
        return super.dao.findPermissions(userInfo);
    }

    /**
     * 根据角色id删除permission_role表
     *
     * @param roleId
     * @return boolean
     * @Date 2018/11/7 11:02 AM
     * @Author wuyanshen
     */
    public boolean deletePR(String roleId) {
        int flag = super.dao.deletePR(roleId);
        if (flag > 0) {
            return true;
        }
        return false;
    }

    public List<String> findPermissionRole(Role role) {
        return super.dao.findPermissionRole(role);
    }

    public boolean deleteRolePermission(Permission permission) {
        int flag = super.dao.deleteRolePermission(permission);
        if (flag > 0) {
            return true;
        } else {
            return false;
        }
    }
}
